package reit.ass3;

import java.util.concurrent.atomic.AtomicInteger;



/**
 * The Class Quantifiable.
 */
class Quantifiable extends Namable implements QuantifiableInterface{

	/** The quantity. */
	private AtomicInteger fQuantity;

	/**
	 * Gets the quantity.
	 *
	 * @return the quantity
	 */
	protected int getfQuantity() {
		return fQuantity.get();
	}

	/**
	 * Sets the quantity.
	 *
	 * @param fQuantity the new quantity
	 */
	protected void setfQuantity(final int fQuantity) {
		this.fQuantity.set(fQuantity);
	}

	/**
	 * Instantiates a new quantifiable.
	 *
	 * @param name the name
	 * @param quantity the quantity
	 */
	public Quantifiable(final String name, final int quantity) {
		super(name);
		fQuantity = new AtomicInteger();
		fQuantity.set(quantity);
	}

	/**
	 * Instantiates a new quantifiable.
	 *
	 * @param other the other
	 */
	public Quantifiable(final Quantifiable other){
		super(other);
		this.fQuantity = new AtomicInteger(getQuantity());
	}

	/* (non-Javadoc)
	 * @see ass3.QuantifiableInterface#getQuantity()
	 */
	@Override
	public int getQuantity() {
		return fQuantity.get();
	}

}
